<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="commons/header :: common-header(~{::title}, ~{::link})">
    <link rel="stylesheet" th:href="@{/css/major.css}">
    <title>专业分类</title>
</head>

<body>
<!-- Header -->
<div th:replace="commons/header :: header"></div>
<script th:inline="javascript">
    suffix = ['专业有哪些', '专业哪个好', '专业怎么样'];
    document.getElementsByTagName('title')[0].innerText = [[${currentSubject.name}]] + suffix[Math.floor(Math.random() * suffix.length)];
</script>
<div class="container">
    <div class="row row-offcanvas row-offcanvas-left content_container">

        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
            <!-- 展示专业种类信息 -->
            <div class="subjects">
                <!--/*@thymesVar id="subjects" type="com.hrong.major.model.Subject"*/-->
                <a th:each="subject:${subjects}"
                   th:href="@{'/majors/'+${subject.id}(page=1, size=8)}">
                    <button class="btn btn-default btn-md"
                            th:classappend="${subject.id eq currentSubject.id ? 'active-btn':(subject.id % 3 eq 0 ? 'btn-success' : (subject.id % 2 eq 0 ? 'btn-warning' : 'btn-info'))}"
                            th:text="${subject.name}"></button>
                </a>
            </div>
            <hr>
            <!-- 搜索框 -->
            <form class="form-group" th:action="@{/majors}" th:method="post" th:object="${searchVo}">
                <div class="col-xs-8 col-sm-10 col-md-10 col-lg-10">
                    <input class="form-control input-lg" placeholder="输入想搜索的专业名称吧~" required="required" th:field="*{name}" type="text">
                </div>
                <div class="col-xs-3 col-sm-2 col-md-2 col-lg-2">
                    <button class="btn btn-info btn-lg" type="submit">搜一搜</button>
                </div>
            </form>
            <div class="clearfloat"></div>
            <div class="hot-div">
                <span class="hot-search-span">热门搜索：</span>
                <form class="form-group form-hot-search" th:action="@{/majors}" th:each="search:${searches}" th:method="post" th:object="${searchVo}">
                    <input hidden="hidden" name="name" th:value="${search.name}" type="text">
                    <button class="btn btn-search"  th:classappend="${search.searchCount % 3 eq 0 ? 'btn-success' : (search.searchCount % 2 eq 0 ? 'btn-warning' : 'btn-info')}" th:text="${search.name}" type="submit"></button>
                </form>
            </div>
            <!--<span class="hot-search-span">热门搜索：</span>
            <a th:each="search:${searches}" th:href="@{'/majors/hot?content='+${search.name}}">
                <button class="btn btn-search"
                        th:classappend="${search.searchCount % 3 eq 0 ? 'btn-success' : (search.searchCount % 2 eq 0 ? 'btn-warning' : 'btn-info')}"
                        th:text="${search.name}"></button>
            </a>-->
            <div class="clearfloat"></div>
            <h3 class="text-center text-warning" th:if="not ${majors} and ${data.isEmpty()}" th:text="没有找到相关专业哦"></h3>
            <!-- 展示专业信息 -->
            <ul class="row major_ul" th:if="${majors}">
                <!--/*@thymesVar id="subjects" type="com.hrong.major.model.Major"*/-->
                <li class="col-xs-12 col-sm-12 col-md-12 col-lg-12 major_li" th:each="major:${majors}">
                    <span class="search_index" th:classappend="${majorStat.index eq 0 ? 'search_index_1':(majorStat.index eq 1 ? 'search_index_2' : (majorStat.index eq 2 ? 'search_index_3' : ''))}" th:text="${majorStat.index+1}"></span>
                    <a class="major_a" th:href="@{'/major/'+${major.id}}" th:text="${major.name}"
                       th:title="${major.name}">
                    </a>
                    <span>&nbsp;&nbsp;</span>
                    <span class="glyphicon glyphicon-hand-left" style="font-size:1.5em"></span>
                </li>
            </ul>
            <!-- 模糊查询显示方式 -->
            <ul class="row major_ul" th:if="${data}">
                <!--/*@thymesVar id="subjects" type="com.hrong.major.model.Major"*/-->
                <li class="col-xs-12 col-sm-12 col-md-12 col-lg-12 search_major_li" th:each="item:${data}">
                    <div class="col-xs-12 col-lg-12">
                        <a class="search_major_name" th:href="@{'/major/'+${item.major.id}}"
                           th:text="${item.major.name}" th:title="${item.major.name}">
                        </a>
                    </div>
                    <div class="col-xs-12 col-lg-12">
                        <p class="search_subject">所属专业类别:
                            <strong th:text="${item.subject.name}"></strong>
                        </p>
                        <button class="btn btn-xs btn-default" th:onclick="querySubjectDesc([[${item.major.id}]],[[${item.subject.id}]])" th:value="${item.major.id}">
                            查看专业类别描述
                        </button>
                    </div>
                </li>
            </ul>
            <!-- 翻页按钮 -->
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12"
                 th:if="${totalPages} and ${totalPages} gt 1 and ${currentSubject}">
                <nav aria-label="">
                    <ul class="pager">
                        <li><a th:if="${pageNum} gt 1"
                               th:href="@{'/majors/'+${currentSubject.id}(page=${pageNum}-1, size=8)}">上一页</a></li>
                        <li th:each="pageNo : ${#numbers.sequence(1, totalPages)}">
                            <a th:if="${pageNum eq pageNo}" href="javascript:void(0);">
                                <span th:text="${pageNo}" th:class="disable-a"></span>
                            </a>
                            <a th:if="${not (pageNum eq pageNo)}"
                               th:href="@{'/majors/'+${currentSubject.id}(page=${pageNo}, size=8)}">
                                <span th:text="${pageNo}"></span>
                            </a>
                        </li>
                        <li><a th:if="${pageNum} lt ${totalPages}"
                               th:href="@{'/majors/'+${currentSubject.id}(page=${pageNum+1}, size=8)}">下一页</a></li>
                    </ul>
                </nav>
            </div>
        </div>
    </div>
</div>
<footer>
    <div th:replace="commons/footer :: footer(~{::script})">
        <script th:src="@{/js/major.js}"></script>
    </div>
</footer>
</body>
</html>
